<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>工程泛联客</title>
<link rel="stylesheet" href="../resource/mp/_assets/css/scrollbar.css?_v=20150112">
<jsp:include page="../../../main/mp/inc.jsp" />
<!-- 	 引入jqmCalendar 文件资源  -->
<link href="../resource/mp/jqmCalendar/jw-jqm-cal.css" rel="stylesheet">
<script src="../resource/mp/jqmCalendar/jw-jqm-cal.js?_v=20140801"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

<script type="text/javascript">
//对Date的扩展，将 Date 转化为指定格式的String
//月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
//年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
//例子： 
//(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
//(new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
Date.prototype.Format = function (fmt) { //author: meizz 
 var o = {
     "M+": this.getMonth() + 1, //月份 
     "d+": this.getDate(), //日 
     "h+": this.getHours(), //小时 
     "m+": this.getMinutes(), //分 
     "s+": this.getSeconds(), //秒 
     "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
     "S": this.getMilliseconds() //毫秒 
 };
 if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
 for (var k in o)
 if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
 return fmt;
}

var firstDo = false;
var firstDate;
$(function(){
		var myDate = new Date();
		if(myDate.getMonth() < 9){
			var month = "0"+(myDate.getMonth()+1);
		}else{
			var month = myDate.getMonth()+1;
		}
		firstDate = myDate.getFullYear()+"-"+month+"-01";
		$.ajax({
			type 	: "POST",
			url 	: '<%=basePath%>mp/ajax-calendar/listCalendarView',
			data    : {"month":firstDate,"proInfoId":null},
			dataType : 'json',
			contentType: "application/x-www-form-urlencoded; charset=utf-8",  
			cache : false,
			success:function(data){
				var cals = [];
				$(data.data.dataRows).each(function(i,v){
					var dateObj =new Date(v.begin['time']);

					var endObj = new Date(v.end['time']);
					var cal={
							"summary" : v.summary,
							"begin" :dateObj,
							"end" :endObj,
							"url":v.url
					}
					cals.push(cal);
				});
				jqmCalendar = $("#calendar").jqmCalendar({
				      events : cals,
				      months : ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
				      days : ["日", "一", "二", "三", "四", "五", "六"],
				      startOfWeek : 0,
				      source : '<%=basePath%>mp/ajax-calendar/listCalendarView',
				      allDayTimeString: ''
				 });
			}
		});

		$("#calendar").bind('change', function(event, date) {
			//用户某一天的切换
            console.debug(date);
            // Fetch the events from the jqm-calendar object stored in the jQuery data
            //var events = $("#calendar").data("jqm-calendar").settings.events;

		});
	});
</script>
</head>
<body>

	<div data-role="page">
	    <div data-role="header" data-position="fixed" data-theme="a">

	    	<!-- 新建按钮 -->
			<jsp:include page="../../../main/mp/actions-popup.jsp"	/>
	    </div>
	    <div data-role="content">
			<div id="scroller">
				<div id="calendar" style="margin:2px 1px 0 1px !important;"></div>
			</div>
		</div>
        <%--<a href="#" data-ajax="false" id="back_to_top" style="bottom:40px;" class="ui-btn ui-corner-all ui-icon-carat-u ui-btn-inline ui-icon-plus ui-btn-icon-top">请假</a>--%>
		<!-- nav 导航 -->
		<jsp:include page="../../../main/mp/nav-panel.jsp" />

    </div>
</body>
</html>
<script>
    $(function(){
        $("[data-role='navbar']").navbar();
        $("[data-role='header'], [data-role='footer']").toolbar();
        //点击请假按钮
        $("#back_to_top").click(function(){
            $("#popupMenu").popup( "close" );
            $("#proinfo-listview-panel").panel( "open" );
            $("#proHandleType").text("leave");
        })
    });
	wx.config({
		debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		appId: '${jsapiSignature.appId}', // 必填，公众号的唯一标识
		timestamp: '${jsapiSignature.timestamp}', // 必填，生成签名的时间戳
		nonceStr: '${jsapiSignature.noncestr}', // 必填，生成签名的随机串
		signature: '${jsapiSignature.noncestr}',// 必填，签名，见附录1
		jsApiList: ['checkJsApi', 'getLocation'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
	});
</script>